#include <sys/eventfd.h>
#include<iostream>
#include<unistd.h>
using namespace std;


int main()
{
  int efd = ::eventfd(0,EFD_CLOEXEC|EFD_NONBLOCK); //initval flag
  if(efd < 0)
  {
     cerr << "create eventfd error" << endl;
     exit(1);
  }
  uint64_t val = 1;
  write(efd,&val,sizeof(val));//1
  val++; 
  write(efd,&val,sizeof(val));//2
  val++;
  write(efd,&val,sizeof(val));//3
  uint64_t res = 0;
  read(efd,&res,sizeof(res));
  cout << "res: " << res << endl;
  return 0;
}
